package com.sss.hloster04;

public class JavaExercise20 {
	public static void main(String[] args) {
		test20();
	}

	/**
	 * 题20； 有一分数序列：2/1，3/2，5/3，8/5，13/8，21/13...求出这个数列的前20项之和
	 */
	private static void test20() {
		double sum = 0, a = 2, b = 1, c = 0;
		for (int i = 1; i <= 20; i++) {
			sum = sum + a / b;
			c = a;
			a = a + b;
			b = c;
		}
		System.out.println("前二十项之和为：" + sum);
	}

}
